put comma in numbers python

59

put comma in numbers python -

num = 2437.68

# Way 1: String Formatting

'{:,}'.format(num)
>>> '2,437.68'


# Way 2: F-Strings

f'{num:,}'
>>> '2,437.68'


# Way 3: Built-in Format Function

format(num, ',')
>>> '2,437.68'

thousands separator python -

>>> num = 10000000
>>> print(f"{num:,}")
10,000,000

Comments

Submit
0 Comments